package com.bto.leasetest;

import com.alibaba.fastjson2.JSONArray;
import com.bto.leasetest.entity.Device;
import com.bto.leasetest.utils.IdUtils;

import java.util.*;
import java.util.concurrent.ForkJoinPool;

public class Main {

//    public static void main(String[] args) {
//        List<String> listA = Arrays.asList("apple", "banana", "cherry");
//        List<String> listB = Arrays.asList("appl", "banana", "cherry");
//
//        boolean result = isSubset(listA, listB);
//        System.out.println(result); // Output: true
//    }
//
//    public static boolean isSubset(List<String> listA, List<String> listB) {
//        Trie trie = new Trie();
//        for (String b : listB) {
//            trie.insert(b);
//        }
//
//        for (String a : listA) {
//            if (!trie.search(a)) {
//                return false;
//            }
//        }
//
//        return true;
//    }
//
//    static class Trie {
//        private Map<Character, Trie> children;
//        private boolean isEndOfWord;
//
//        public Trie() {
//            children = new HashMap<>();
//            isEndOfWord = false;
//        }
//
//        public void insert(String word) {
//            Trie node = this;
//            for (char c : word.toCharArray()) {
//                node = node.children.computeIfAbsent(c, k -> new Trie());
//            }
//            node.isEndOfWord = true;
//        }
//
//        public boolean search(String word) {
//            Trie node = this;
//            for (char c : word.toCharArray()) {
//                node = node.children.get(c);
//                if (node == null) {
//                    return false;
//                }
//            }
//            return node.isEndOfWord;
//        }
//    }



    public static void main(String[] args) {
        String lenStr = String.valueOf(30);
        String[] strList = {"ZUJIAN", "NBQ","CJQ","PDX"};
//        String[] strList = {"A", "B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"};
        List<Device> devices = new ArrayList<>();
        for (String deviceStr : strList) {
            for (int i = 1; i <= Integer.parseInt(lenStr); i++) {
                Device device = new Device();
                device.setDeviceType(deviceStr);
                device.setManufacturer("广州__" + deviceStr);
                device.setSpecificationsModel("001__" + deviceStr);
                String str = String.valueOf(i);
                if (str.length() < lenStr.length()) {
                    int len = lenStr.length() - str.length();
                    for (int j = 0; j < len; j++) {
                        str = "0" + str;
                    }
                }
                device.setDeviceId(  deviceStr  + "_A_" + str );
                devices.add(device);
            }
        }
        JSONArray jsonArray = new JSONArray(devices);
        System.out.println("jsonArray = " + jsonArray);
    }

    public static boolean isSubset(List<String> listA, List<String> listB) {
        Set<String> setB = new HashSet<>(listB);

        ForkJoinPool forkJoinPool = new ForkJoinPool();

        return forkJoinPool.submit(() ->
                listA.parallelStream().allMatch(setB::contains)
        ).join();
    }




}
